/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package jpa.entities;

import java.io.Serializable;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author KenShin
 */
@Entity
@Table(name = "StudentCourse", catalog = "SupportiveLearning", schema = "dbo")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "StudentCourse.findAll", query = "SELECT s FROM StudentCourse s"),
    @NamedQuery(name = "StudentCourse.findByStudentId", query = "SELECT s FROM StudentCourse s WHERE s.studentCoursePK.studentId = :studentId"),
    @NamedQuery(name = "StudentCourse.findByCourseId", query = "SELECT s FROM StudentCourse s WHERE s.studentCoursePK.courseId = :courseId"),
    @NamedQuery(name = "StudentCourse.findByMark", query = "SELECT s FROM StudentCourse s WHERE s.mark = :mark"),
    @NamedQuery(name = "StudentCourse.findByFileUpload", query = "SELECT s FROM StudentCourse s WHERE s.fileUpload = :fileUpload")})
public class StudentCourse implements Serializable {
    private static final long serialVersionUID = 1L;
    @EmbeddedId
    protected StudentCoursePK studentCoursePK;
    @Basic(optional = false)
    @NotNull
    @Column(name = "Mark")
    private double mark;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 250)
    @Column(name = "FileUpload")
    private String fileUpload;
    @JoinColumn(name = "StudentId", referencedColumnName = "StudentId", insertable = false, updatable = false)
    @ManyToOne(optional = false)
    private Students students;
    @JoinColumn(name = "CourseId", referencedColumnName = "CourseId", insertable = false, updatable = false)
    @ManyToOne(optional = false)
    private Course course;

    public StudentCourse() {
    }

    public StudentCourse(StudentCoursePK studentCoursePK) {
        this.studentCoursePK = studentCoursePK;
    }

    public StudentCourse(StudentCoursePK studentCoursePK, double mark, String fileUpload) {
        this.studentCoursePK = studentCoursePK;
        this.mark = mark;
        this.fileUpload = fileUpload;
    }

    public StudentCourse(int studentId, int courseId) {
        this.studentCoursePK = new StudentCoursePK(studentId, courseId);
    }

    public StudentCoursePK getStudentCoursePK() {
        return studentCoursePK;
    }

    public void setStudentCoursePK(StudentCoursePK studentCoursePK) {
        this.studentCoursePK = studentCoursePK;
    }

    public double getMark() {
        return mark;
    }

    public void setMark(double mark) {
        this.mark = mark;
    }

    public String getFileUpload() {
        return fileUpload;
    }

    public void setFileUpload(String fileUpload) {
        this.fileUpload = fileUpload;
    }

    public Students getStudents() {
        return students;
    }

    public void setStudents(Students students) {
        this.students = students;
    }

    public Course getCourse() {
        return course;
    }

    public void setCourse(Course course) {
        this.course = course;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (studentCoursePK != null ? studentCoursePK.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof StudentCourse)) {
            return false;
        }
        StudentCourse other = (StudentCourse) object;
        if ((this.studentCoursePK == null && other.studentCoursePK != null) || (this.studentCoursePK != null && !this.studentCoursePK.equals(other.studentCoursePK))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "jpa.entities.StudentCourse[ studentCoursePK=" + studentCoursePK + " ]";
    }
    
}
